package classrecord;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class CreateTablesPUPRecords {

	public static void main(String args[]) {
		Connection c = null;
		Statement stmt = null;
		try {
			Class.forName("org.sqlite.JDBC");
			c = DriverManager.getConnection("jdbc:sqlite.records.sqlite");
			c.setAutoCommit(false);
			System.out.println("Opened database successfully");

			stmt = c.createStatement();
			String sql = "CREATE TABLE STUDENTNUMBERTBL (RECORD_NUMBER INTEGER PRIMARY KEY AUTOINCREMENT, STUDENT_NUMBER TEXT NOT NULL, IUD_FLAG INTEGER(1), CREATE_PID TEXT, CREATE_DATETIME DATETIME DEFAULT CURRENT_TIMESTAMP, DELETE_PID TEXT, DELETE_TIMESTAMP TIMESTAMP, UPDATE_PID TEXT, UPDATE_TIMESTAMP TIMESTAMP)";
			stmt.executeUpdate(sql);
			stmt.close();
			c.close();
		} catch (Exception e) {
			System.err.println(e.getClass().getName() + ": " + e.getMessage());
			System.exit(0);
		}
		System.out.println("Table created successfully");
	}

}
